package com.personal.system.controller.approval;

import java.util.List;
import com.personal.system.entity.approval.AuditRuleDetail;
import org.springframework.http.ResponseEntity;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.personal.system.service.act.AuditRuleDetailService;

/**
 * 审批流程节点Controller
 *
 * @author hhdd
 * @date 2023-02-17 09:57:45
 */
@RestController
@RequestMapping("/system/detail")
public class AuditRuleDetailController {

    @Resource
    private AuditRuleDetailService auditRuleDetailService;

    /**
     * 查询审批流程节点列表
     */
    @GetMapping("/list")
    public ResponseEntity list(AuditRuleDetail auditRuleDetail) {

        List<AuditRuleDetail> list = auditRuleDetailService.selectAuditRuleDetailList(auditRuleDetail);
        return ResponseEntity.ok(list);
    }

    /**
     * 导出审批流程节点列表
     */
    @GetMapping("/export")
    public void export(AuditRuleDetail auditRuleDetail) {

        List<AuditRuleDetail> list = auditRuleDetailService.selectAuditRuleDetailList(auditRuleDetail);
    }

    /**
     * 获取审批流程节点详细信息
     */
    @GetMapping(value = "/details/{ruleDetailId}")
    public ResponseEntity getInfo(@PathVariable("ruleDetailId") String ruleDetailId) {

        return ResponseEntity.ok(auditRuleDetailService.selectAuditRuleDetailById(ruleDetailId));
    }

    /**
     * 新增审批流程节点
     */
    @PostMapping("/add")
    public ResponseEntity add(@RequestBody AuditRuleDetail auditRuleDetail) {

        return ResponseEntity.ok(auditRuleDetailService.insertAuditRuleDetail(auditRuleDetail));
    }

    /**
     * 修改审批流程节点
     */
    @PutMapping("/edit")
    public ResponseEntity edit(@RequestBody AuditRuleDetail auditRuleDetail) {

        return ResponseEntity.ok(auditRuleDetailService.updateAuditRuleDetail(auditRuleDetail));
    }

    /**
     * 删除审批流程节点
     */
    @DeleteMapping("/delete/{ruleDetailIds}")
    public ResponseEntity remove(@PathVariable String[] ruleDetailIds) {

        return ResponseEntity.ok(auditRuleDetailService.deleteAuditRuleDetailByIds(ruleDetailIds));
    }
}
